<!DOCTYPE html>
<html ng-app="loginApp">

<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <title>调度中心</title>

    <link rel="stylesheet" href="bootstrap/css/font-awesome.min.css">

    <link rel='stylesheet prefetch' href='bootstrap/css/bootstrap.min.css'>

    <link rel="stylesheet" href="bootstrap/css/style.css" media="screen" type="text/css" />

</head>

<body class="login-page">

<div class="login-form" ng-controller="loginCtrl">

    <div class="login-content">

        <div class="form-login-error">
            <h3>Invalid login</h3>
            <p>Enter <strong>demo</strong>/<strong>demo</strong> as login and password.</p>
        </div>

        <form method="post" role="form" id="form_login">

            <div class="form-group">

                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-user"></i>
                    </div>

                    <input type="text" class="form-control" name="username" ng-model="formInfo.username" placeholder="用户名" autocomplete="off" />
                </div>

            </div>

            <div class="form-group">

                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-key"></i>
                    </div>

                    <input type="password" class="form-control" name="password" ng-model="formInfo.password" placeholder="密码" autocomplete="off" />
                </div>

            </div>

            <div class="form-group">
                <button type="submit" ng-click="processForm()" class="btn btn-primary btn-block btn-login">
                    <i class="fa fa-sign-in"></i>
                    登陆
                </button>
            </div>

            <!-- Implemented in v1.1.4 -->				<div class="form-group">
            <em>-  -</em>
        </div>

            <div class="form-group">

                <button type="button" class="btn btn-default btn-lg btn-block facebook-button">
                    &#160;&#160;
                    <i class="fa fa-sign-out"></i>
                    |  调度中心登陆入口
                </button>

            </div>


        </form>



    </div>

</div>
</div>
<script src="libs/angular/angular.min.js" charset="utf-8"></script>
<script type="text/javascript">
    var app = angular.module("loginApp", []);
    app.controller("loginCtrl", function ($scope,$window,$http,$location) {
        $scope.formInfo = {

        };
        $scope.processForm = function() {
            var url = $location.absUrl();
            url = url.substr(0,url.lastIndexOf("/"))+"/user/login.do";
            url+="?username="+$scope.formInfo.username;
            url+="&password="+$scope.formInfo.password;
            $http({
                method  : 'POST',
                url     : url,
                headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
            }).success(function(data) {
                if (data.status) {
                    var url = $location.absUrl();
                    url = url.substr(0,url.lastIndexOf("/"))+"/index.html";
                    $window.location.href=url;
                } else {
                    alert(JSON.stringify(data))
                }

            });
        };
    });
</script>
</body>
</html>